package org.blogwu.learn.netty学习.chapter0.bio2;

import java.io.*;
import java.net.Socket;

public class Client {

    public static void main(String[] args) {

        try (Socket socket = new Socket("127.0.0.1", 9999);
             OutputStream outputStream = socket.getOutputStream();
             BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream, "utf-8"));
             InputStream inputStream = socket.getInputStream();
             BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "utf-8"));
        ) {

            bufferedWriter.write("服务端是个大傻逼！");
            bufferedWriter.newLine();
            bufferedWriter.flush();
            String ss = bufferedReader.readLine();
            System.out.println("服务端返回信息：" + ss);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
